import {StackActions, NavigationActions } from 'react-navigation';
import { NavigationParams, NavigationRoute } from 'react-navigation';

let _container; // eslint-disable-line

export function setContainer(container) {
    _container = container;
}

export function reset(routeName, params) {
    _container.dispatch(
        StackActions.reset({
            index: 0,
            actions: [
                NavigationActions.navigate({
                    type: 'Navigation/NAVIGATE',
                    routeName,
                    params,
                }),
            ],
        }),
    );
}

export function navigate(routeName, params) {
    _container.dispatch(
        NavigationActions.navigate({
            type: 'Navigation/NAVIGATE',
            routeName,
            params,
        }),
    );
}

export default {
    setContainer,
    navigate,
    reset,
};